﻿<cfsilent>
	<cfscript>
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		depId = event.getArg("DepID","101");
		
		sql = "SELECT a.institute_id,
					   a.institute_name 
				FROM t_institute a 
				WHERE a.institute_id = :depId ";
				
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_department = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
				a.tch_id, a.tch_name, b.tp_series 
				FROM t_teacher a  
					INNER JOIN t_technical_position b ON b.tp_id = a.tp_id 
				WHERE 
					a.institute_id = :depId 
					AND 
					SUBSTR(b.tp_id,3,1) = '1'
				ORDER BY a.tch_name";
			
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_professor = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
					a.tp_id, a.tp_series 
				FROM t_technical_position a  
				WHERE 
					SUBSTR(a.tp_id, 1, 2) IN ('01','06','07','08','13') 
				ORDER BY 
					a.tp_id";
					
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_technicalPosition = queryObj.execute( sql=sql ).getResult();
		
													
		sql = "SELECT 
				a.tch_id, a.tch_name, b.tp_series 
				FROM t_teacher a  
					INNER JOIN t_technical_position b ON b.tp_id = a.tp_id 
				WHERE 
					a.institute_id = :depId 
					AND 
					SUBSTR(b.tp_id,3,1) = '2'
				ORDER BY a.tch_name";
			
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_associateProfessor = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
				a.tch_type, a.tch_type_name
				FROM t_teacher_type a 
				ORDER BY 
					a.tch_type";
					
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_type = queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT 
					a.edu_id, a.edu_background
				FROM t_teacher_educational a  
				WHERE 
					SUBSTR(a.edu_id, 1, 1) in ('0','1','2','3','4') 
				ORDER BY 
					a.edu_id";	
			
		queryObj = new query( datasource=application.dnsSlave  );
		
		rs_educational = queryObj.execute( sql=sql ).getResult();
		
		/*在校教师*/
		sql = "SELECT 
					a.tch_id, a.tch_name, a.tch_sex, 
					b.tp_series, c.edu_background, 
					case when a.tch_email like '%@email.unknown' then '-' else a.tch_email end tch_email, 
					case when a.tch_tel is null then '-' else a.tch_tel end tch_tel, 
					d.user_login 
				FROM t_teacher a  
					   INNER JOIN t_technical_position b ON b.tp_id = a.tp_id  
					   INNER JOIN t_teacher_educational c ON c.edu_id = a.edu_id 
					   INNER JOIN t_user d on d.user_id = a.tch_id 
				WHERE 
					a.institute_id = :depId 
					AND 
					d.role = '1' 
				ORDER BY a.tch_name";
			
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_teacher = queryObj.execute( sql=sql ).getResult();
		
		/*离校教师*/
		sql = "SELECT 
					a.tch_id, a.tch_name, a.tch_sex, 
					b.tp_series, c.edu_background, 
					case when a.tch_email like '%@email.unknown' then '-' else a.tch_email end tch_email, 
					case when a.tch_tel is null then '-' else a.tch_tel end tch_tel, 
					d.user_login 
				FROM t_teacher a  
					   INNER JOIN t_technical_position b ON b.tp_id = a.tp_id  
					   INNER JOIN t_teacher_educational c ON c.edu_id = a.edu_id 
					   INNER JOIN t_user d on d.user_id = a.tch_id 
				WHERE 
					a.institute_id = :depId 
					AND 
					d.role = '0' 
				ORDER BY a.tch_name";
			
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_teacherLeave = queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "师资工作量 - 师资管理 - 院系(部)概况 - " & rs_department.institute_name);

		passArgs = structNew();
		structInsert( passArgs, "DepID", rs_department.institute_id, true );

		currentTab = event.getArg("TabID", "labTeacher");
		
		if ( rs_professor.recordCount or rs_associateProfessor.recordCount ) {
			currentTab = event.getArg("TabID", "labTeacherTeam");
		}
		
		/* 搜索教师档案 */
		keyword = event.getArg("Keywords");
		
		rs_teacherSearch = queryNew("tch_id");
		
		if ( len(keyword) ) {
			
			sql = "SELECT 
					a.tch_id, a.tch_name, 
					b.tp_series 
					FROM t_teacher a 
						 INNER JOIN t_technical_position b ON b.tp_id = a.tp_id   
					WHERE 
						a.institute_id = :depId 
						AND 
						a.tch_name LIKE :condition 
						OR 
						a.tch_id LIKE :condition  
					ORDER BY a.tch_name";
					
			queryObj = new query( datasource=application.dnsSlave ,maxRows = 60 );
			queryObj.addParam( name="condition", value=keyword&"%", cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
			
			rs_teacherSearch = queryObj.execute( sql=sql ).getResult();
			
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
            <div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('teacherDocument')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">其它院系</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>师资资源 - <cfoutput>#rs_department.institute_name#</cfoutput>
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<cfif rs_professor.recordCount or rs_associateProfessor.recordCount >
							<span <cfif currentTab eq "labTeacherTeam">class="active"</cfif> id="labTeacherTeam" tabTarget="TeacherTeam">教授团队</span>
						</cfif>
						<span <cfif currentTab eq "labTeacher">class="active"</cfif> id="labTeacher" tabTarget="Teacher">在校教师</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索教师档案</span>
                              <span <cfif currentTab eq "labAdd">class="active"</cfif> id="labAdd" tabTarget="Add">添加教师信息</span>
                              <span <cfif currentTab eq "labTeacherLeave">class="active"</cfif> id="labTeacherLeave" tabTarget="TeacherLeave">离校教师</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>				
				</script>
                
				<cfif rs_professor.recordCount or rs_associateProfessor.recordCount >
				
					<div id="TeacherTeam" class="tabContent">
					
						<cfif rs_professor.recordCount>
					
							<div class="noticeBlock">
								<h3>正高职称</h3>
								<hr/>
							</div>
					
							<div class="clearfix">
                                <cfloop query="rs_professor"  >
									<cfset structInsert( passArgs, "TCHID", rs_professor.tch_id, true) />
									<div class="UISmallUserCard">
										<div class="cardContent">
											<a href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"><img class="img" src="<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/graphic/userSmall.png" style="background-image: url('<cfoutput>#getContextRoot()#</cfoutput>/acadmicManager/teacher/portrait/<cfoutput>#rs_professor.tch_id#</cfoutput>.jpg');"></a>
											<div class="cardDetail">
												<h3><a href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"><cfoutput>#rs_professor.tch_name#</cfoutput></a> <span class="uid">(<cfoutput>#rs_professor.tch_id#</cfoutput>)</span></h3>
												<p><cfoutput>#rs_professor.tp_series#</cfoutput></p>
											</div>
										</div>
									</div>
								</cfloop>
							</div>
					
						</cfif>
					
					
						<cfif rs_associateProfessor.recordCount>

							<div class="noticeBlock">
								<h3>副高职称</h3>
								<hr/>
							</div>
						
							<div class="clearfix">
                                <cfloop query="rs_associateProfessor"  >
									<cfset structInsert( passArgs, "TCHID", rs_associateProfessor.tch_id, true) />
									<div class="UISmallUserCard">
										<div class="cardContent">
											<a href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"><img class="img" src="<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/graphic/userSmall.png" style="background-image: url('<cfoutput>#getContextRoot()#</cfoutput>/acadmicManager/teacher/portrait/<cfoutput>#rs_associateProfessor.tch_id#</cfoutput>.jpg');"></a>
											<div class="cardDetail">
												<h3><a href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"><cfoutput>#rs_associateProfessor.tch_name#</cfoutput></a> <span class="uid">(<cfoutput>#rs_associateProfessor.tch_id#</cfoutput>)</span></h3>
												<p><cfoutput>#rs_associateProfessor.tp_series#</cfoutput></p>
											</div>
										</div>
									</div>
								</cfloop>
							</div>
						
						</cfif>
							
					</div>
				
				</cfif>

				
				<div id="Teacher" class="tabContent">
					
					<div class="noticeBlock">
						<h3>部门师资情况（在校教师）</h3>
						<hr />
					</div>
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td>职工号</td>
								<td>姓名</td>
								<td>性别</td>
								<td>登录名</td>
								<td>电子邮件</td>
								<td>联系电话</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_teacher"  >
								<cfset row++ />
								<cfset structInsert( passArgs, "TCHID", rs_teacher.tch_id, true) />
								<tr>
									<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
									<td><span class="numeric"><cfoutput>#rs_teacher.tch_id#</cfoutput></span></td>
									<td><cfoutput>#rs_teacher.tch_name#</cfoutput></td>
									<td><cfoutput>#dictAdvice.getGender( rs_teacher.tch_sex )#</cfoutput></td>
									<td><cfoutput>#rs_teacher.user_login#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_teacher.tch_email#</cfoutput></span></td>
									<td><span class="numeric"><cfoutput>#rs_teacher.tch_tel#</cfoutput></span></td>
									<td><a class="edit" href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
				</div>
                    
                    <div id="TeacherLeave" class="tabContent">
					
					<div class="noticeBlock">
						<h3>部门师资情况(限制登录教师)</h3>
						<hr />
					</div>
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="18"></td>
								<td>职工号</td>
								<td>姓名</td>
								<td>性别</td>
								<td>登录名</td>
								<td>电子邮件</td>
								<td>联系电话</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_teacherLeave"  >
								<cfset row++ />
								<cfset structInsert( passArgs, "TCHID", rs_teacherLeave.tch_id, true) />
								<tr>
									<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
									<td><span class="numeric"><cfoutput>#rs_teacherLeave.tch_id#</cfoutput></span></td>
									<td><cfoutput>#rs_teacherLeave.tch_name#</cfoutput></td>
									<td><cfoutput>#dictAdvice.getGender( rs_teacherLeave.tch_sex )#</cfoutput></td>
									<td><cfoutput>#rs_teacherLeave.user_login#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_teacherLeave.tch_email#</cfoutput></span></td>
									<td><span class="numeric"><cfoutput>#rs_teacherLeave.tch_tel#</cfoutput></span></td>
									<td><a class="edit" href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"></a></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
				</div>
				
				<div id="Search" class="tabContent">
					
				<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('instituteTeacher')#</cfoutput>">
					
					<input type="hidden" name="TabID" value="labSearch" />
					<input type="hidden" name="DepID" value="<cfoutput>#depId#</cfoutput>" />
						
					<div class="label">
						<b>工号或姓名</b>
						<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
					</div>
					<hr/>
					<div class="lable">
						<input class="button1" type="submit" value="搜索" />
					</div>
					
				</form>
					
				<cfif rs_teacherSearch.recordCount>

					<div class="clearfix">
                        <cfloop query="rs_teacherSearch"  >
							<cfset structInsert( passArgs, "TCHID", rs_teacherSearch.tch_id, true) />
							<cfset structInsert( passArgs, "DepID", depId, true) />
							<div class="UISmallUserCard">
								<div class="cardContent">
									<a href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"><img class="img" src="<cfoutput>#getProperty('cdnServer')#</cfoutput><cfoutput>#getContextRoot()#</cfoutput>/acadmicRes/assets/graphic/userSmall.png" style="background-image: url('<cfoutput>#getContextRoot()#</cfoutput>/acadmicManager/teacher/portrait/<cfoutput>#rs_teacherSearch.tch_id#</cfoutput>.jpg');"></a>
									<div class="cardDetail">
										<h3><a href="<cfoutput>#buildURL('teacherProfile', passArgs)#</cfoutput>"><cfoutput>#rs_teacherSearch.tch_name#</cfoutput></a> <span class="uid">(<cfoutput>#rs_teacherSearch.tch_id#</cfoutput>)</span></h3>
										<p><cfoutput>#rs_teacherSearch.tp_series#</cfoutput></p>
									</div>
								</div>
							</div>
						</cfloop>
					</div>
					
				</cfif>
					
			</div>
               
               <div id="Add" class="tabContent">
					
					<div class="noticeBlock">
						<h3>添加教师信息</h3>
						<hr/>
					</div>
					
					<form id="formEdit" onSubmit="javascript:return processVerfiyForm('formEdit');" class="formWrapper" method="post" action="<cfoutput>#buildURL('teacherAddDo')#</cfoutput>">
						
						
						<div class="label">
							<span class="req">*</span><b>教师姓名</b>
							<input name="TeacherName" id="TeacherName" type="text" class="typeTextTiny inlinePart" verification="required" maxlength="15" value="" />
						</div>
						
						<div class="label">
							<b>性别</b>
							<input name="TeacherSex" type="radio" class="typeRadio" value="1" />男
							<input name="TeacherSex" type="radio" class="typeRadio" value="2"  checked="checked"/>女
						</div>
						
                              <input name="TeacherIDCard" id="TeacherIDCard" type="hidden" class="typeIDCard inlinePart" maxlength="18" value="511129198809090311" />
						<!---<div class="label">
							<span class="req">*</span><b>身份证号</b>
							<input name="TeacherIDCard" id="TeacherIDCard" type="text" class="typeIDCard inlinePart" maxlength="18" value="511129198809090311" />
							<p class="notice">教师个人证件号码,建议填写，如果没有可以用上面系统默认数据</p>
						</div>--->
						
						<hr/>
                              
                               <input name="InstituteID" id="InstituteID" type="hidden" class="inlinePart" maxlength="18" value="<cfoutput>#rs_department.institute_id#</cfoutput>" />
                               
                               <input name="TypeCode" id="TypeCode" type="hidden" class="inlinePart" maxlength="18" value="<cfoutput>#rs_type.tch_type#</cfoutput>" />
						
						<!---<div class="label">
							<b>工作部门</b>
							<select name="InstituteID" id="InstituteID" class="inlinePart">
                                        <cfloop query="rs_department"  >
                                                     <option value="<cfoutput>#rs_department.institute_id#</cfoutput>"><cfoutput>#rs_department.institute_name#</cfoutput></option>
								</cfloop>
							</select>
							
							教师类别
							
							<select name="TypeCode" id="TypeCode" class="inlinePart">
                                <cfloop query="rs_type" >
									<option value="<cfoutput>#rs_type.tch_type#</cfoutput>"><cfoutput>#rs_type.tch_type_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>--->
                              
                            <input name="TechnicalPositionSeries" type="hidden" value="01" />
                            <input name="TechnicalPositionID" type="hidden" value="010" />

						<!---<div class="label">
							<b>职称</b>
							<select name="TechnicalPositionSeries" id="TechnicalPositionSeries" class="inlinePart"></select>
							<select name="TechnicalPositionID" id="TechnicalPositionID" class="inlinePart"></select>
						</div>--->

						<div class="label">
							<b>学历</b>
							<select name="EduCode" id="EduCode">
                                <cfloop query="rs_educational"  >
									<option value="<cfoutput>#rs_educational.edu_id#</cfoutput>"><cfoutput>#rs_educational.edu_background#</cfoutput></option>
								</cfloop>
							</select>
							
						</div>
						
						<hr/>
						
						<div class="label">
							<b>电子邮件</b>
							<cfset emailAddress = "" />
							<cfif find( "@email.unknown", emailAddress )>
								<cfset emailAddress = "" />
							</cfif>
							<input name="EmailAddress" id="EmailAddress" type="text" class="typeEnglish" verification="email" maxlength="120" value="unknown@unknown.email" />
							
						</div>
						
						<div class="label">
							<b>联系电话</b>
							<input name="TeacherTelephone" id="TeacherTelephone" type="text" class="typeEnglish" maxlength="16" value="" />
							
						</div>
                              <hr/>
                              <div class="label">
							<b>登录用户名</b>
							<input name="username" id="username" type="text" class="typeEnglish" verification="required" maxlength="16" value="" />
							<p class="notice">如果用户名已经存在，系统将在用户名后面添加一个随机数，你可以添加之后再查看或者修改</p>
						</div>
                              
                              <div class="label">
							<b>登录密码</b>
							<input name="password" id="password" type="text" class="typeEnglish" verification="required" maxlength="16" value="000000" />
							<p class="notice">'000000'为默认初始密码，可以自己修改</p>
						</div>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
						</div>
						
					</form>
					
					<cfset i = 0 />
					<cfset targetSeries = "01" />
					<cfset targetPosition = "010" />
					
				
				</div>
				
			</div>
		</li>
	</ul>
</div>